<jsp:include page="/templates/header.jsp"/>
<%@page import="database.Queries" %>
<%@page import="java.util.LinkedList" %>
<%@page import="java.sql.SQLException" %>
<%@page import="java.net.URLEncoder"%>
<%@page import="java.sql.Connection" %>
<%@page import="database.Connect" %>
<%@page import="java.sql.SQLException"%>

<script type="text/javascript" src="/salonmorandsmigi/js/confirm.js"></script>

<div id="dialog" title="Are you sure?" style="display:none">
	<p>Are you sure you want to delete the student?</p>
</div>
<%
	Connection con=null;
	try{
		con=Connect.getConnection();
		con.setAutoCommit(false);
		LinkedList<String> students = Queries.getStudentNames(con);
		con.commit();
		if (students==null){ %> 
			There are no Students registered to the Site
		<%}
		else{
			%>
			<div class="students" id="students">
				<table border="3" width="30%">
			<%
		 	for (int i=0;i<students.size();i++){
		 		String name = students.get(i);
		 		name = URLEncoder.encode(name,"UTF-8");
		 		%>
		 			<tr align="center" id=<%=name%>><td><a href="/salonmorandsmigi/admin/student.jsp?name=<%=name%>"> <%=name%> </a></td>
		 				<td width="20%"><img class="delete" src="/salonmorandsmigi/images/delete.png" id="<%=name%>"/></td>
		 			</tr>
		 	<% }%>
		 		</table>
		 	</div>
		<%}
	}
	catch (SQLException e){
		con.rollback();
		  out.write("SERVER ERROR! PLEASE TRY AGAIN");
	}
	finally{
		if(con!=null) 
		{
			con.setAutoCommit(true);
		  	con.close();
		}
	}
%>

<jsp:include page="/templates/sidebar.jsp"/>
<jsp:include page="/templates/footer.jsp"/>